package com.potenza.training.interview.controller;

import com.potenza.training.interview.entity.InterviewClassEntity;
import com.potenza.training.interview.service.InterviewClassService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;



/**
 * 班级表
 *
 * @author lihonggang
 * @email lihonggang@gmail.com
 * @date 2021-07-28 18:57:10
 */
@RestController
@RequestMapping("interview/interviewclass")
public class InterviewClassController {
    @Autowired
    private InterviewClassService interviewClassService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("interview:interviewclass:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = interviewClassService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("interview:interviewclass:info")
    public R info(@PathVariable("id") Long id){
		InterviewClassEntity interviewClass = interviewClassService.getById(id);

        return R.ok().put("interviewClass", interviewClass);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("interview:interviewclass:save")
    public R save(@RequestBody InterviewClassEntity interviewClass){
		interviewClassService.save(interviewClass);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("interview:interviewclass:update")
    public R update(@RequestBody InterviewClassEntity interviewClass){
		interviewClassService.updateById(interviewClass);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("interview:interviewclass:delete")
    public R delete(@RequestBody Long[] ids){
		interviewClassService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
     * 查询学生状态
     */
    @RequestMapping("/findByStudent/{StudentId}")
    @RequiresPermissions("interview:interviewclass:findByStudent")
    public R findByStudent(@PathVariable Integer StudentId){
        List<InterviewClassEntity> list = interviewClassService.findByStudent(StudentId);

        return R.ok().put("list",list);
    }
}
